﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Web;

namespace ProjectBase.Core
{
    public static class ResourceManager
    {
        #region Create URL
        /// <summary>
        ///     Fixes the provided relative path ('web/virtualPath/'.. ver. 'web/..')
        /// </summary>
        /// <param name = "target">expected relative path, e.g. 'js/myscript.js'</param>
        /// <returns>corrected relative path (e.g. '/virtualPath/js/myscritp.js' or '/js/myscritp.js' if needed)</returns>
        public static string CreateUrl(string target)
        {
            return HttpContext.Current.CreateUrl(target);
        }
        #endregion Create URL

        #region GetLocalized

        /// <summary>
        ///     provides the culture dependent phrase based on a Key (and Area)
        /// </summary>
        /// <param name = "key">The unique key for a phrase</param>
        /// <param name = "area">more precise setting (can be nullOrEmpty)</param>
        /// <returns>Translated phrase</returns>
        public static string GetLocalized(this string key, string area = null)
        {
            var result = HttpContext.GetGlobalResourceObject(area, key, CultureInfo.CurrentUICulture);
            if (result.Is())
            {
                return result.ToString();
            }
            return string.Empty;
        }
        #endregion GetLocalized
    }
}
